#! /usr/bin/env python3

import sqlite3

class TimeStamp:
    def parse(self, count, line):
        print(f'count={count}, line={line}', end='')
        pass

class CPUStat:
    def parse(self, count, line):
        print(f'count={count}, line={line}', end='')

class MemInfo:
    def parse(self, count, line):
        print(f'count={count}, line={line}', end='')


def parse(filename):

    timestamp = TimeStamp()
    cpustat   = CPUStat()
    meminfo   = MemInfo()

    count = 0
    start = False

    with open(filename, 'r') as file:
        lines = file.readlines()
        for line in lines:
            if line.startswith('TIME'):
                group = timestamp
                count += 1
                start = True
                timestamp.parse(count, line)
            elif start and line.startswith('CPU'):
                cpustat.parse(count, line)
            elif start and line.startswith('MEM'):
                meminfo.parse(count, line)


if __name__ == '__main__':
    parse('log')
